using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media.Imaging;
using Common;
using Common.Enum;
using SExperiment;

namespace Converters
{
	public class HistorySmallMouseOverImagePathConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			BitmapImage result = null;
			if (value != null && value != DependencyProperty.UnsetValue && value is string)
			{
				string text = value as string;
				if (!string.IsNullOrEmpty(text))
				{
					ExperimentTemporary experimentTemporaryInfo = Experiment.GetExperimentTemporaryInfo(text);
					switch (experimentTemporaryInfo.Type)
					{
					case EProjectType.HRM:
						result = (BitmapImage)Utility.GetResource("HRMExpHistoryMouseOverSmallBitmap");
						break;
					case EProjectType.AD:
						result = (BitmapImage)Utility.GetResource("ADExpHistoryMouseOverSmallBitmap");
						break;
					case EProjectType.AQ:
						result = (BitmapImage)Utility.GetResource("AQExpHistoryMouseOverSmallBitmap");
						break;
					case EProjectType.Melt:
						result = (BitmapImage)Utility.GetResource("MeltExpHistoryMouseOverSmallBitmap");
						break;
					case EProjectType.RQ:
						result = (BitmapImage)Utility.GetResource("RQExpHistoryMouseOverSmallBitmap");
						break;
					default:
						result = (BitmapImage)Utility.GetResource("DefaultExperimentHistoryMouseOverSmallBitmap");
						break;
					}
				}
			}
			return result;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			return value;
		}
	}
}
